<?php
/*
 * @Description    : 消息推送数据预处理任务
 * @Version        : 1.0.0
 * @Author         : QianLong
 * @Date           : 2020-01-22 15:56:35
 * @LastEditors    : QianLong
 * @LastEditTime   : 2024-01-16 17:02:23
 */

declare(strict_types=1);

namespace App\Job;

use Hyperf\AsyncQueue\Job;
use App\Common\RedisCache;
use App\Service\Push\DdWork;
use App\Service\Push\Feishu;
use App\Service\Push\WxWork;
use Yurun\Util\HttpRequest;

class PushDataAlertJob extends Job
{
    public $params;
    public $redisCache;

    public function __construct($params)
    {
        $this->params = $params;
        $this->redisCache = new RedisCache;
    }

    public function handle()
    {
        if (!empty($this->params) && is_array($this->params)) {
            $collection = mongodb2()->selectCollection('send_push_log_' . $this->params['uid']);
            $serverInfo = $this->redisCache->getPushServer($this->params['ps_id']);
            // $pushSetting = $this->redisCache->getPushSetting($this->params['uid']);
            if (isset($this->params['psl_id']) && !empty($this->params['psl_id'])) {
                $postData['_id'] = $this->params['psl_id'];
            } else {
                $postData['_id'] = createULId('PSL-');
                $postData['pt_id'] = $this->params['pt_id'];
                $postData['uid'] = $this->params['uid'];
                $postData['ps_id'] = $this->params['ps_id'];
                $postData['send_content'] = '';
                $postData['cid'] = '';
                $params = $this->params;
                unset($params['uid'], $params['single_cid']);
                $postData['params'] = json_encode($params, JSON_UNESCAPED_UNICODE);
                unset($params);
                $postData['title'] = $this->params['title'];
                $postData['content'] = $this->params['content'];
                $postData['send_result'] = false;
                $postData['type'] = $serverInfo['type'];
                $postData['send_error'] = '';
                if ($serverInfo['type'] == 'alert') {
                    $postData['platform'] = $serverInfo['platform_alert'];
                } else {
                    $postData['platform'] = $serverInfo['platform'];
                }

                $postData['send_result_data'] = '';
                $postData['task_id'] = '';
                $postData['is_read'] = 0;
                $postData['read_time'] = 0;
                $postData['send_time'] = time();
                $postData['date'] = date('Ymd');
                $postData['hour'] = date('YmdH');
                $postData['only_hour'] = date('H') . ':00';
                $postData['hour_stamp'] = strtotime(date('Y-m-d H') . ':00:00');
                $postData['month'] = date('Ym');
                $postData['year'] = date('Y');
                // mongodb2()->send_push_log->insertOne($postData);
                $collection->insertOne($postData);
                // 1=升序，-1=降序
                (new \App\Service\Common)->mongodbIndexCreate($collection, 'uid_send_time', ['uid' => 1, 'send_time' => -1]);
                (new \App\Service\Common)->mongodbIndexCreate($collection, 'uid_send_time_ps_id', ['uid' => 1, 'send_time' => -1, 'ps_id' => -1]);
            }
            if (empty($serverInfo)) {
                $collection->updateOne(['_id' => $postData['_id']], ['$set' => ['send_error' => '推送配置不存在或推送配置ID不正确']]);
                return true;
            }
            if ($serverInfo['status'] != 1) {
                $collection->updateOne(['_id' => $postData['_id']], ['$set' => ['send_error' => '推送配置未启用']]);
                return true;
            }
            $serverInfo['platform_alert'] = is_array($serverInfo['platform_alert']) ? $serverInfo['platform_alert'] : explode(',', $serverInfo['platform_alert']);
            $resultBooleanList = [];
            if (in_array('phone', $serverInfo['platform_alert'])) {
                $this->params['phone'] = $serverInfo['platform_alert_phone'];
                $this->params['ss_id'] = $serverInfo['platform_alert_ss_id'];
                $this->params['st_id'] = $serverInfo['platform_alert_st_id'];
                $this->params['dev_key'] = $this->params['dev_key'];
                $smsServerInfo = $this->redisCache->getSmsServer($this->params['ss_id']);
                $smsResult = (new \App\Service\Common)->smsSend($this->params, $smsServerInfo);
                $updateLog['smsResult'] = $smsResult;
                $updateLog['smsPhone'] = $serverInfo['platform_alert_phone'];
                $updateLog['smsServerId'] = $serverInfo['platform_alert_ss_id'];
                $updateLog['smsTplId'] = $serverInfo['platform_alert_st_id'];
                if (isset($smsResult['code']) && $smsResult['code'] == 200) {
                    $updateLog['smsStatus'] = true;
                    $updateLog['smsStatusMsg'] = '';
                    if (!in_array(true, $resultBooleanList)) {
                        $resultBooleanList[] = true;
                    }
                } else {
                    $updateLog['smsStatus'] = false;
                    $updateLog['smsStatusMsg'] = $smsResult['msg'];
                    if (!in_array(false, $resultBooleanList)) {
                        $resultBooleanList[] = false;
                    }
                }
            }
            if (in_array('email', $serverInfo['platform_alert'])) {
                $this->params['email'] = $serverInfo['platform_alert_email'];
                $this->params['es_id'] = $serverInfo['platform_alert_es_id'];
                $this->params['et_id'] = $serverInfo['platform_alert_et_id'];
                $this->params['dev_key'] = $this->params['dev_key'];
                $emailServerInfo = $this->redisCache->getEmailServer($this->params['es_id']);
                $emailResult = (new \App\Service\Common)->emailSend($this->params, $emailServerInfo);
                $updateLog['emailResult'] = $emailResult;
                $updateLog['emailList'] = $serverInfo['platform_alert_email'];
                $updateLog['emailServerId'] = $serverInfo['platform_alert_es_id'];
                $updateLog['emailTplId'] = $serverInfo['platform_alert_et_id'];
                if (isset($emailResult['code']) && $emailResult['code'] == 200) {
                    $updateLog['emailStatus'] = true;
                    $updateLog['emailStatusMsg'] = '';
                    if (!in_array(true, $resultBooleanList)) {
                        $resultBooleanList[] = true;
                    }
                } else {
                    $updateLog['emailStatus'] = false;
                    $updateLog['emailStatusMsg'] = $emailResult['msg'];
                    if (!in_array(false, $resultBooleanList)) {
                        $resultBooleanList[] = false;
                    }
                }
            }
            if (in_array('goeasy', $serverInfo['platform_alert'])) {
                $goEasyResult = (new \App\Service\Push\GoEasy($serverInfo))->pushContent($this->params);
                $updateLog['goEasyResult'] = $goEasyResult;
                if (isset($goEasyResult['code']) && $goEasyResult['code'] == 200) {
                    $updateLog['goEasyStatus'] = true;
                    $updateLog['goEasyStatusMsg'] = '';
                    if (!in_array(true, $resultBooleanList)) {
                        $resultBooleanList[] = true;
                    }
                } else {
                    $updateLog['goEasyStatus'] = false;
                    $updateLog['goEasyStatusMsg'] = isset($goEasyResult['msg'])? $goEasyResult['msg']:'';
                    if (!in_array(false, $resultBooleanList)) {
                        $resultBooleanList[] = false;
                    }
                }
            }
            $updateLog['wworkResult'] = [];
            $updateLog['ddingResult'] = [];
            // $http = new HttpRequest;
            $wxWork = new WxWork($serverInfo);
            $ddWork = new DdWork($serverInfo);
            $feishu = new Feishu($serverInfo);
            switch ($this->params['msg_type']) {
                case 'text':
                    if (in_array('weixin_work', $serverInfo['platform_alert'])) {
                        $wworkResult = $wxWork->pushBotText($this->params);
                        $updateLog['wworkResult'] = json_encode($wworkResult, JSON_UNESCAPED_UNICODE);
                        if (isset($wworkResult['errcode']) && $wworkResult['errcode'] == 0) {
                            $updateLog['wworkStatus'] = true;
                            $updateLog['wworkStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['wworkStatus'] = false;
                            $updateLog['wworkStatusMsg'] = '[' . $wworkResult['errcode'] . ']' . $wworkResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('weixin_app', $serverInfo['platform_alert'])) {
                        $wworkAppResult = $wxWork->pushAppText($this->params);
                        $updateLog['wworkAppResult'] = json_encode($wworkAppResult, JSON_UNESCAPED_UNICODE);
                        if (isset($wworkAppResult['errcode']) && $wworkAppResult['errcode'] == 0) {
                            $updateLog['wworkAppStatus'] = true;
                            $updateLog['wworkAppStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['wworkAppStatus'] = false;
                            $updateLog['wworkAppStatusMsg'] = '[' . $wworkAppResult['errcode'] . ']' . $wworkAppResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('dingding', $serverInfo['platform_alert'])) {
                        $ddingResult = $ddWork->pushBotText($this->params);
                        $updateLog['ddingResult'] = json_encode($ddingResult, JSON_UNESCAPED_UNICODE);
                        if (isset($ddingResult['errcode']) && $ddingResult['errcode'] == 0) {
                            $updateLog['ddingStatus'] = true;
                            $updateLog['ddingStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['ddingStatus'] = false;
                            $updateLog['ddingStatusMsg'] = '[' . $ddingResult['errcode'] . ']' . $ddingResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('feishuqun', $serverInfo['platform_alert'])) {
                        $feishuqunResult = $feishu->pushBotText($this->params);
                        $updateLog['feishuqunResult'] = json_encode($feishuqunResult, JSON_UNESCAPED_UNICODE);
                        if (isset($feishuqunResult['code']) && $feishuqunResult['code'] == 0) {
                            $updateLog['feishuqunStatus'] = true;
                            $updateLog['feishuqunStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['feishuqunStatus'] = false;
                            $updateLog['feishuqunStatusMsg'] = '[' . $feishuqunResult['code'] . ']' . $feishuqunResult['msg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    break;
                case 'pic':
                    if (in_array('weixin_work', $serverInfo['platform_alert'])) {
                        $wworkResult = $wxWork->pushBotImage($this->params);;
                        $updateLog['wworkResult'] = json_encode($wworkResult, JSON_UNESCAPED_UNICODE);
                        if (isset($wworkResult['errcode']) && $wworkResult['errcode'] == 0) {
                            $updateLog['wworkStatus'] = true;
                            $updateLog['wworkStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['wworkStatus'] = false;
                            $updateLog['wworkStatusMsg'] = '[' . $wworkResult['errcode'] . ']' . $wworkResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('weixin_app', $serverInfo['platform_alert'])) {
                        $wworkAppResult = $wxWork->pushAppImage($this->params);
                        $updateLog['wworkAppResult'] = json_encode($wworkAppResult, JSON_UNESCAPED_UNICODE);
                        if (isset($wworkAppResult['errcode']) && $wworkAppResult['errcode'] == 0) {
                            $updateLog['wworkAppStatus'] = true;
                            $updateLog['wworkAppStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['wworkAppStatus'] = false;
                            $updateLog['wworkAppStatusMsg'] = '[' . $wworkAppResult['errcode'] . ']' . $wworkAppResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    break;
                case 'tuwen':
                    if (in_array('weixin_work', $serverInfo['platform_alert'])) {
                        $wworkResult = $wxWork->pushBotTuwen($this->params);
                        $updateLog['wworkResult'] = json_encode($wworkResult, JSON_UNESCAPED_UNICODE);
                        if (isset($wworkResult['errcode']) && $wworkResult['errcode'] == 0) {
                            $updateLog['wworkStatus'] = true;
                            $updateLog['wworkStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['wworkStatus'] = false;
                            $updateLog['wworkStatusMsg'] = '[' . $wworkResult['errcode'] . ']' . $wworkResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('weixin_app', $serverInfo['platform_alert'])) {
                        $wworkAppResult = $wxWork->pushAppTuwen($this->params);
                        $updateLog['wworkAppResult'] = json_encode($wworkAppResult, JSON_UNESCAPED_UNICODE);
                        if (isset($wworkAppResult['errcode']) && $wworkAppResult['errcode'] == 0) {
                            $updateLog['wworkAppStatus'] = true;
                            $updateLog['wworkAppStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['wworkAppStatus'] = false;
                            $updateLog['wworkAppStatusMsg'] = '[' . $wworkAppResult['errcode'] . ']' . $wworkAppResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('dingding', $serverInfo['platform_alert'])) {
                        $ddingResult = $ddWork->pushBotTuwen($this->params);
                        $updateLog['ddingResult'] = json_encode($ddingResult, JSON_UNESCAPED_UNICODE);
                        if (isset($ddingResult['errcode']) && $ddingResult['errcode'] == 0) {
                            $updateLog['ddingStatus'] = true;
                            $updateLog['ddingStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['ddingStatus'] = false;
                            $updateLog['ddingStatusMsg'] = '[' . $ddingResult['errcode'] . ']' . $ddingResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('feishuqun', $serverInfo['platform_alert'])) {
                        $feishuqunResult = $feishu->pushBotTuwen($this->params);
                        $updateLog['feishuqunResult'] = json_encode($feishuqunResult, JSON_UNESCAPED_UNICODE);
                        if (isset($feishuqunResult['code']) && $feishuqunResult['code'] == 0) {
                            $updateLog['feishuqunStatus'] = true;
                            $updateLog['feishuqunStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['feishuqunStatus'] = false;
                            $updateLog['feishuqunStatusMsg'] = '[' . $feishuqunResult['code'] . ']' . $feishuqunResult['msg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    break;
                case 'file':
                    # code...
                    break;
                case 'markdown':
                    if (in_array('weixin_work', $serverInfo['platform_alert'])) {
                        $wworkResult = $wxWork->pushBotMD($this->params);
                        $updateLog['wworkResult'] = json_encode($wworkResult, JSON_UNESCAPED_UNICODE);
                        if (isset($wworkResult['errcode']) && $wworkResult['errcode'] == 0) {
                            $updateLog['wworkStatus'] = true;
                            $updateLog['wworkStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['wworkStatus'] = false;
                            $updateLog['wworkStatusMsg'] = '[' . $wworkResult['errcode'] . ']' . $wworkResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('weixin_app', $serverInfo['platform_alert'])) {
                        $wworkAppResult = $wxWork->pushAppMD($this->params);
                        $updateLog['wworkAppResult'] = json_encode($wworkAppResult, JSON_UNESCAPED_UNICODE);
                        if (isset($wworkAppResult['errcode']) && $wworkAppResult['errcode'] == 0) {
                            $updateLog['wworkAppStatus'] = true;
                            $updateLog['wworkAppStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['wworkAppStatus'] = false;
                            $updateLog['wworkAppStatusMsg'] = '[' . $wworkAppResult['errcode'] . ']' . $wworkAppResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('dingding', $serverInfo['platform_alert'])) {
                        $ddingResult = $ddWork->pushBotMD($this->params);
                        $updateLog['ddingResult'] = json_encode($ddingResult, JSON_UNESCAPED_UNICODE);
                        if (isset($ddingResult['errcode']) && $ddingResult['errcode'] == 0) {
                            $updateLog['ddingStatus'] = true;
                            $updateLog['ddingStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['ddingStatus'] = false;
                            $updateLog['ddingStatusMsg'] = '[' . $ddingResult['errcode'] . ']' . $ddingResult['errmsg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    if (in_array('feishuqun', $serverInfo['platform_alert'])) {
                        $feishuqunResult = $feishu->pushBotMD($this->params);
                        $updateLog['feishuqunResult'] = json_encode($feishuqunResult, JSON_UNESCAPED_UNICODE);
                        if (isset($feishuqunResult['code']) && $feishuqunResult['code'] == 0) {
                            $updateLog['feishuqunStatus'] = true;
                            $updateLog['feishuqunStatusMsg'] = '';
                            if (!in_array(true, $resultBooleanList)) {
                                $resultBooleanList[] = true;
                            }
                        } else {
                            $updateLog['feishuqunStatus'] = false;
                            $updateLog['feishuqunStatusMsg'] = '[' . $feishuqunResult['code'] . ']' . $feishuqunResult['msg'];
                            if (!in_array(false, $resultBooleanList)) {
                                $resultBooleanList[] = false;
                            }
                        }
                    }
                    break;
            }
            if (in_array('mp_weixin_template', $serverInfo['platform_alert']) && isset($this->params['template_data']) && !empty($this->params['template_data'])) {
                $touser = (isset($this->params['template_touser']) && !empty($this->params['template_touser'])) ? $this->params['template_touser'] : $serverInfo['platform_alert_mp_weixin_template_openid'];
                $template_id = (isset($this->params['template_id']) && !empty($this->params['template_id'])) ? $this->params['template_id'] : $serverInfo['platform_alert_mp_weixin_template_template_id'];
                $template_miniprogram = (isset($this->params['template_miniprogram']) && !empty($this->params['template_miniprogram'])) ? $this->params['template_miniprogram'] : '';
                $template_url = (isset($this->params['template_url']) && !empty($this->params['template_url'])) ? $this->params['template_url'] : 'http://www.21ds.cn';
                $mpTemplateResult = (new \App\Service\MpWeixin)->sendTemplateMsg($serverInfo['platform_alert_mp_weixin_template_mwid'], $touser, $template_id, $this->params['template_data'], $template_url, $template_miniprogram);
                $updateLog['mpTemplateResult'] = $mpTemplateResult;
                $updateLog['mpTemplateTouser'] = $touser;
                $updateLog['mpTemplateTemplate'] = $template_id;
                if (isset($mpTemplateResult['errcode']) && $mpTemplateResult['errcode'] == 0) {
                    $updateLog['mpTemplateStatus'] = true;
                    $updateLog['mpTemplateStatusMsg'] = '';
                    if (!in_array(true, $resultBooleanList)) {
                        $resultBooleanList[] = true;
                    }
                } else {
                    $updateLog['mpTemplateStatus'] = false;
                    $updateLog['mpTemplateStatusMsg'] = $mpTemplateResult['errmsg'];
                    if (!in_array(false, $resultBooleanList)) {
                        $resultBooleanList[] = false;
                    }
                }
            }
            if (in_array('api_url', $serverInfo['platform_alert']) && isset($serverInfo['platform_api_url']) && !empty($serverInfo['platform_api_url'])) {
                $http = new HttpRequest;
                $http->timeout(3000);
                if (!isset($serverInfo['platform_api_url_password']) || empty($serverInfo['platform_api_url_password'])) {
                    $apiResultObj = $http->post($serverInfo['platform_api_url'], $this->params);
                }else{
                    $apiResultObj = $http->header('X-Dev-Token', $serverInfo['platform_api_url_password'])->post($serverInfo['platform_api_url'], $this->params);
                }
                $apiResult = $apiResultObj->body();
                $updateLog['apiResult'] = $apiResult;
                if (1 == 1) {
                    $updateLog['apiStatus'] = true;
                    $updateLog['apiStatusMsg'] = '';
                    if (!in_array(true, $resultBooleanList)) {
                        $resultBooleanList[] = true;
                    }
                } else {
                    $updateLog['apiStatus'] = false;
                    $updateLog['apiStatusMsg'] = isset($goEasyResult['msg']) ? $goEasyResult['msg'] : '';
                    if (!in_array(false, $resultBooleanList)) {
                        $resultBooleanList[] = false;
                    }
                }
            }
            $updateLog['alertStatus'] = 0;
            if (count($resultBooleanList) == 1) {
                if ($resultBooleanList[0] == true) {
                    $updateLog['alertStatus'] = 1;
                } else {
                    $updateLog['alertStatus'] = -1;
                }
            } else {
                $updateLog['alertStatus'] = 2;
            }
            $collection->updateOne(['_id' => $postData['_id']], ['$set' => $updateLog]);
            unset($postData, $updateLog, $serverInfo, $templateContent, $wxWork, $ddWork, $feishu);
            // if (!isset($this->params['psl_id']) || empty($this->params['psl_id'])) {
            //     $this->insertLog($this->params['ps_id'], $this->params['uid'], $serverInfo['platform'], $serverInfo['type']);
            // }
            return true;
        }
    }
    // public function insertLog($id, $uid, $platform, $type)
    // {
    //     $where['hour'] = date('YmdH');
    //     $where['ps_id'] = $id;
    //     $where['platform'] = $platform;
    //     $hasLog = mongodb2()->send_push_log_tj->findOne($where);
    //     if (empty($hasLog)) {
    //         $insert['_id'] = createULId();
    //         $insert['date'] = date('Ymd');
    //         $insert['hour'] = date('YmdH');
    //         $insert['only_hour'] = date('H') . ':00';
    //         $insert['hour_stamp'] = strtotime(date('Y-m-d H') . ':00:00');
    //         $insert['month'] = date('Ym');
    //         $insert['year'] = date('Y');
    //         $insert['create'] = time();
    //         $insert['ps_id'] = $id;
    //         $insert['platform'] = $platform;
    //         $insert['type'] = $type;
    //         $insert['uid'] = (int) $uid;
    //         $insert['sv'] = 1;
    //         $insert['rv'] = 0;
    //         mongodb2()->send_push_log_tj->insertOne($insert);
    //     } else {
    //         mongodb2()->send_push_log_tj->updateOne($where, ['$inc' => ['sv' => 1]]);
    //     }
    // }
}
